package cn.wolfcode.car.service.impl;

import cn.wolfcode.car.domain.Consumption;
import cn.wolfcode.car.domain.Permission;
import cn.wolfcode.car.domain.Role;
import cn.wolfcode.car.mapper.ConsumptionMapper;
import cn.wolfcode.car.qo.BusinessReportQueryObject;
import cn.wolfcode.car.qo.ConsumptionQueryObject;
import cn.wolfcode.car.service.IConsumptionService;
import cn.wolfcode.car.vo.BusinessReportVO;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.shiro.crypto.hash.Md5Hash;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service
@Transactional
public class ConsumptionServiceImpl implements IConsumptionService {

    @Autowired
    private ConsumptionMapper consumptionMapper;

    @Override
    public int delete(Long id) {
        return consumptionMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int save(Consumption record) {
        return consumptionMapper.insert(record);
    }

    @Override
    public Consumption get(Long id) {
        return consumptionMapper.selectByPrimaryKey(id);
    }

    @Override
    public PageInfo<Consumption> list(ConsumptionQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        List<Consumption> list = consumptionMapper.selectForPage(qo);
        return new PageInfo<>(list);
    }

    @Override
    public int update(Consumption record) {
        return consumptionMapper.updateByPrimaryKey(record);
    }

    @Override
    public void updateStatus(Long id, Integer status) {
        consumptionMapper.updateStatus(id, status);
    }

    @Override
    public void updateStatusShenhe(Long id, Integer status, Date date, Long empid) {
        consumptionMapper.updateStatusShenhe(id, status, date, empid);
    }

    @Override
    public void updateStatusShenheHuaiZhang(Long id, Integer status, Date date, Long auditorid) {
        consumptionMapper.updateStatusShenheHuaiZhang(id, status, date, auditorid);
    }

    @Override
    public PageInfo<BusinessReportVO> selectByGroup(BusinessReportQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        List<BusinessReportVO> list = consumptionMapper.selectByGroup(qo);
        return new PageInfo<>(list);

    }

    @Override
    public List<BusinessReportVO> selectByGroupNotLimit(BusinessReportQueryObject qo) {
        return consumptionMapper.selectByGroup(qo);
    }


}
